home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_078 / mandelvroom / disp.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  18KB  |  787 lines

  1.  /**************************************************************************
  2.  *
  3.  *                 MandelVroom Display Setup/Cleanup
  4.  *
  5.  *                         Kevin L. Clague
  6.  *
  7.  *                        Copyright (C) 1987
  8.  *
  9.  **************************************************************************/
  10.  
  11. #include "mand.h"
  12.  
  13. extern struct Window *MandWind, *ContWind, *PalWind;
  14. extern struct NewWindow NewMand, NewCont, NewPal;
  15. extern struct Menu Menu;
  16.  
  17. extern struct Windows {
  18.   struct Windows *NextWindow;
  19.   struct Window  *Window;
  20. } *WindowList;
  21.  
  22. extern struct MenuItem ViewModeSubs[];
  23.  
  24. extern SHORT  *ContourBase,Ceiling;
  25.  
  26. extern SHORT CountX, CountY;
  27.  
  28. struct IntuitionBase *IntuitionBase;
  29. struct GfxBase       *GfxBase;
  30. struct MathBase      *MathBase;
  31.  
  32. struct Screen   *screen = (struct Screen *) NULL;
  33. struct RastPort *rp;
  34. struct ViewPort *vp;
  35.  
  36. USHORT YScale, XScale;
  37.  
  38. USHORT *BabyBrotPointer = (USHORT *) NULL;
  39. USHORT *BabyToPointer   = (USHORT *) NULL;
  40. USHORT *SleepyPointer   = (USHORT *) NULL;
  41.  
  42. /* pointer types  */
  43. #define UNINITIALIZED 0
  44. #define NORMPOINTER   1
  45. #define TOPOINTER     2
  46. #define SLEEPYPOINTER 3
  47.  
  48. UBYTE   PointerType = UNINITIALIZED;
  49.  
  50. SHORT  SavePalette[32];
  51. SHORT  Inited;
  52.  
  53. extern USHORT CmdMode;
  54.  
  55. struct NewScreen NewScreen = {
  56.    0,0,                      /* start position           */
  57.    320, 200, 5,              /* width, height, depth     */
  58.    (UBYTE) 0, (UBYTE) 1,     /* detail pen, block pen    */
  59.    (USHORT) NULL,            /* HIRES, INTERLACE, SPRITES, DUAL, HAM */
  60.    CUSTOMSCREEN,             /* screen type              */
  61.    (struct TextAttr *) NULL, /* font to use              */
  62.    (UBYTE *) "                MandelVroom v1.50       by Kevin L. Clague",
  63.    (struct Gadget *) NULL    /* pointer to extra gadgets */
  64. };
  65.  
  66. /***************************************************************************
  67.  *
  68.  * Open the Libraries and custom screen
  69.  *
  70.  **************************************************************************/
  71.  
  72. /*
  73.  * Open the libraries
  74.  */
  75. OpenLibs() {
  76.   IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",0);
  77.   if (IntuitionBase == (struct IntuitionBase *) NULL) {
  78.      printf("Couldn't get Intuition\n");
  79.      return(100);
  80.      }
  81.  
  82.   GfxBase = (struct GfxBase *) OpenLibrary("graphics.library",0);
  83.   if (GfxBase == (struct GfxBase *) NULL) {
  84.      printf("Couldn't get Graphics\n");
  85.      return(100);
  86.      }
  87.  
  88.   MathBase = (struct MathBase *) OpenLibrary("mathffp.library",0);
  89.   if (MathBase == (struct MathBase *) NULL) {
  90.      printf("Couldn't get MathFFP\n");
  91.      return(100);
  92.      }
  93.  
  94.   return(0);
  95. } /* OpenLibs */
  96.  
  97. /*
  98.  * Close the libraries used
  99.  */
  100. CloseLibs() {
  101.   if (IntuitionBase != (struct IntuitionBase *) NULL) CloseLibrary(IntuitionBase);
  102.   if (GfxBase       != (struct GfxBase *) NULL) CloseLibrary(GfxBase);
  103.   if (MathBase      != (struct MathBase *) NULL) CloseLibrary(MathBase);
  104. } /* CloseLibs */
  105.  
  106. /*
  107.  * Open the display
  108.  */
  109. OpenDisp()
  110. {
  111.   SHORT i;
  112.  
  113.   struct Window *OpenMyWind();
  114.   struct Screen *OpenScreen();
  115.  
  116.   if (NewScreen.ViewModes & HIRES) {
  117.     NewScreen.Width = 640;
  118.     if ( NewScreen.Depth > 4 ) NewScreen.Depth = 4;
  119.     XScale = 1;
  120.  
  121.   } else {
  122.     NewScreen.Width = 320;
  123.     XScale = 0;
  124.   }
  125.  
  126.   if (NewScreen.ViewModes & INTERLACE) {
  127.     NewScreen.Height = 400;
  128.     YScale = 1;
  129.   } else {
  130.     NewScreen.Height = 200;
  131.     YScale = 0;
  132.   }
  133.  
  134.   screen = OpenScreen( (struct NewScreen *) &NewScreen);
  135.  
  136.   if (screen == (struct Screen *) NULL) {
  137.      AndDie("Can't open new screen!\n");
  138.   }
  139.   InitViewModesSubs();
  140.   InitDepthSubs();
  141.   InitGenSubs();
  142.   InitMaxISubs();
  143.  
  144.   AllocateMice();
  145.  
  146.   OpenMandWind();
  147.  
  148.   if ( MandWind == (struct Window *) NULL ) {
  149.     AndDie("Can't open Picture window\n");
  150.   }
  151.  
  152.   rp = MandWind->RPort;
  153.   vp = &screen->ViewPort;
  154.  
  155.   if ( Inited )
  156.     LoadRGB4(vp, &SavePalette[0], 32);
  157.   Inited = 1;
  158.  
  159.   return(0);
  160. } /* opendisp */
  161.  
  162. /*
  163.  *  Close the screen
  164.  */
  165. CloseDisp() {
  166.   LONG i;
  167.  
  168.   ClosePalWind();
  169.   CloseContWind();
  170.   CloseMandWind();
  171.  
  172.   if (Inited)
  173.     for (i = 0; i < 32; i++) SavePalette[i] = GetRGB4(vp->ColorMap, i);
  174.  
  175.   if ( screen )   CloseScreen(screen);
  176.  
  177.   FreeMice();
  178.  
  179. } /* CloseDisp */
  180.  
  181. AndDie( ErrMsg )
  182.   char *ErrMsg;
  183. {
  184.   extern SHORT *CountBase;
  185.  
  186.   printf("%s\n", ErrMsg);
  187.  
  188.   CloseLibs();
  189.  
  190.   CloseDisp();
  191.  
  192.   if (CountBase)
  193.     FreeMem( CountBase, CountX * CountY * sizeof( USHORT ) );
  194.  
  195.   printf("Something unrecoverable happened!!!\n");
  196.   exit(0);
  197. }
  198.  
  199. /***************************************************************************
  200.  *
  201.  * Open and Close Window tools
  202.  *
  203.  **************************************************************************/
  204.  
  205. /*
  206.  *  Open a window and put it in the window list
  207.  */
  208. struct Window *OpenMyWind(NewWind, Screen, Gadgets, Width, Height,
  209.                           MaxWidth, MaxHeight)
  210.   struct NewWindow *NewWind;
  211.   struct Screen *Screen;
  212.   struct Gadget *Gadgets;
  213.   SHORT  Width, Height, MaxWidth, MaxHeight;
  214. {
  215.   struct Window *Window, *OpenWindow();
  216.   struct Windows *Windows;
  217.  
  218.   NewWind->Screen = Screen;
  219.   NewWind->FirstGadget = Gadgets;
  220.  
  221.   NewWind->Width = Width << XScale;
  222.   NewWind->Height = Height << YScale;
  223.  
  224.   NewWind->MaxWidth = MaxWidth << XScale;
  225.   NewWind->MaxHeight = MaxHeight << YScale;
  226.  
  227.   Window = OpenWindow( (struct NewWindow *) NewWind);
  228.  
  229.   if (Window == (struct Window *) NULL) {
  230.     DispErrMsg("Can't open new window",0);
  231.     return( (struct Window *) NULL);
  232.   }
  233.  
  234.   Windows = (struct Windows *) AllocMem(sizeof(struct Windows), MEMF_CLEAR);
  235.  
  236.   if (Windows == (struct Windows *) NULL) {
  237.     DispErrMsg("Can't malloc Windows. Out of RAM!!",0);
  238.     return( (struct Window *) NULL);
  239.   }
  240.  
  241.   Windows->Window = Window;
  242.   if (WindowList)
  243.     Windows->NextWindow = WindowList;
  244.   WindowList = Windows;
  245.  
  246.   SetMenuStrip(Window, &Menu);
  247.  
  248.   return(Window);
  249. } /* OpenMyWind */
  250.  
  251. /*
  252.  * Remove the window from the window list,
  253.  *   deallocate all the gadgets associated with this window
  254.  */
  255. CloseMyWind(Window,Gadgets)
  256.   struct Window *Window;
  257.   struct Gadget *Gadgets;
  258. {
  259.   struct Windows *Windows = WindowList, *PrevWinds = WindowList;
  260.  
  261.   if (Window) {
  262.  
  263.      /* get rid of the menu */
  264.      ClearMenuStrip(Window);
  265.  
  266.      /* get rid of the previous pointer */
  267.      ClearPointer(Window);
  268.  
  269.      if (Window == Windows->Window) {
  270.        WindowList = WindowList->NextWindow;
  271.        FreeMem(Windows,sizeof(struct Windows));
  272.      } else {
  273.        while (Windows && Windows->Window != Window) {
  274.          PrevWinds = Windows;
  275.          Windows = Windows->NextWindow;
  276.        }
  277.        if (Windows) {
  278.          PrevWinds->NextWindow = Windows->NextWindow;
  279.          FreeMem(Windows,sizeof(struct Windows));
  280.        }
  281.      }
  282.      CloseWindow(Window);
  283.      if (Gadgets)
  284.        FreeGadgets(Gadgets);
  285.   }
  286. } /* CloseMyWind */
  287.  
  288. /*************************************************************************
  289.  *
  290.  * Allocate and ititialize gadget tools
  291.  *
  292.  ************************************************************************/
  293.  
  294. /*
  295.  * Make a generic boolean gadget
  296.  */
  297. struct Gadget *MakeBool(x,y,xd,yd,c,id)
  298.   SHORT  x,y,xd,yd;
  299.   UBYTE  c;
  300.   USHORT id;
  301. {
  302.   struct Gadget *NewGadget;
  303.   struct Image  *NewImage;
  304.  
  305.   NewGadget = (struct Gadget *)
  306.     AllocMem( (LONG) sizeof(struct Gadget), (LONG) MEMF_CLEAR );
  307.   if (NewGadget == (struct Gadget *) NULL)
  308.     return((struct Gadget *) NULL);
  309.  
  310.   NewImage = (struct Image *)
  311.     AllocMem( (LONG) sizeof(struct Image), (LONG) MEMF_CHIP | MEMF_CLEAR );
  312.   if (NewImage == (struct Image *) NULL) {
  313.     FreeMem( NewGadget, (LONG) sizeof(struct Gadget));
  314.     return((struct Gadget *) NULL);
  315.   }
  316.   NewGadget->LeftEdge = x << XScale;
  317.   NewGadget->TopEdge  = y << YScale;
  318.   NewGadget->Width    = xd << XScale;
  319.   NewGadget->Height   = yd << YScale;
  320.   NewGadget->Flags    = GADGHCOMP | GADGIMAGE;
  321.   NewGadget->Activation = GADGIMMEDIATE;
  322.   NewGadget->GadgetRender = (APTR) NewImage;
  323.   NewGadget->GadgetType = BOOLGADGET;
  324.   NewGadget->GadgetID = id;
  325.  
  326.   NewImage->Width = xd << XScale;
  327.   NewImage->Height = yd << YScale;
  328.   NewImage->PlaneOnOff = c;
  329.  
  330.   return(NewGadget);
  331. } /* MakeBool */
  332.  
  333. /*
  334.  * Make a generic potentiometer gadget
  335.  */
  336. struct Gadget *MakePot(x, y, xd, yd, id, cnt)
  337.   SHORT  x,y,xd,yd;
  338.   USHORT id;
  339.   USHORT cnt;
  340. {
  341.   struct Gadget   *NewGadget;
  342.   struct PropInfo *NewInfo;
  343.   struct Image    *NewImage;
  344.  
  345.   NewGadget = (struct Gadget *)
  346.     AllocMem( (LONG) sizeof(struct Gadget), MEMF_CLEAR );
  347.   if (NewGadget == (struct Gadget *) NULL)
  348.     return((struct Gadget *) NULL);
  349.  
  350.   NewImage = (struct Image *)
  351.     AllocMem( (LONG) sizeof(struct Image), (LONG) MEMF_CHIP | MEMF_CLEAR );
  352.   if (NewImage == (struct Image *) NULL) {
  353.     FreeMem( NewGadget, (LONG) sizeof(struct Gadget));
  354.     return((struct Gadget *) NULL);
  355.   }
  356.   NewInfo = (struct PropInfo *)
  357.     AllocMem( (LONG) sizeof(struct PropInfo), MEMF_CLEAR );
  358.   if (NewInfo == (struct PropInfo *) NULL) {
  359.     FreeMem( NewGadget, (LONG) sizeof(struct Gadget));
  360.     FreeMem( NewImage,  (LONG) sizeof(struct Image));
  361.     return((struct Gadget *) NULL);
  362.   }
  363.   NewGadget->LeftEdge = x << XScale;
  364.   NewGadget->TopEdge  = y << YScale;
  365.   NewGadget->Width    = xd << XScale;
  366.   NewGadget->Height   = yd << YScale;
  367.   NewGadget->Flags    = GADGHIMAGE | GADGIMAGE;
  368.   NewGadget->Activation   = RELVERIFY;
  369.   NewGadget->GadgetType   = PROPGADGET;
  370.   NewGadget->GadgetRender = (APTR) NewImage;
  371.   NewGadget->SelectRender = (APTR) NewImage;
  372.   NewGadget->SpecialInfo  = (APTR) NewInfo;
  373.   NewGadget->GadgetID     = id;
  374.  
  375.   NewImage->PlaneOnOff = 1;
  376.   NewImage->Width  = 4 << XScale;
  377.   NewImage->Height = 3 << YScale;
  378.  
  379.   NewInfo->Flags = PROPBORDERLESS | FREEVERT;
  380.  
  381.   return(NewGadget);
  382. } /* MakePot */
  383.  
  384. /*
  385.  * Make an IntuiText structure
  386.  */
  387. struct IntuiText *MakeIntui(str, x, y, frontpen, backpen, drawmode )
  388.   UBYTE *str;
  389.   SHORT  x, y;
  390.   UBYTE  frontpen, backpen, drawmode;
  391. {
  392.   struct IntuiText *NewIntui;
  393.  
  394.   NewIntui = (struct IntuiText *)
  395.     AllocMem( (LONG) sizeof(struct IntuiText), (LONG) MEMF_CLEAR );
  396.  
  397.   if (NewIntui == (struct IntuiText *) NULL)
  398.     return((struct IntuiText *) NULL);
  399.  
  400.   NewIntui->FrontPen = frontpen;
  401.   NewIntui->BackPen  = backpen;
  402.   NewIntui->DrawMode = drawmode;
  403.   NewIntui->LeftEdge = x << XScale;
  404.   NewIntui->TopEdge  = y << YScale;
  405.  
  406.   NewIntui->IText    = str;
  407.  
  408.   return(NewIntui);
  409. } /* MakeIntui */
  410.  
  411. /*
  412.  * Free a string of gadgets
  413.  */
  414. FreeGadgets(FirstGadget)
  415.   struct Gadget *FirstGadget;
  416. {
  417.   struct Gadget *NextGadget;
  418.  
  419.   while (FirstGadget) {
  420.     if (FirstGadget->GadgetRender)
  421.       FreeMem(FirstGadget->GadgetRender, (LONG) sizeof(struct Image));
  422.  
  423.     if (FirstGadget->SpecialInfo)
  424.       FreeMem(FirstGadget->SpecialInfo, (LONG) sizeof(struct PropInfo));
  425.  
  426.     if (FirstGadget->GadgetText)
  427.       FreeMem(FirstGadget->GadgetText, (LONG) sizeof(struct IntuiText));
  428.  
  429.     NextGadget = FirstGadget->NextGadget;
  430.     FreeMem(FirstGadget, (LONG) sizeof(struct Gadget));
  431.     FirstGadget = NextGadget;
  432.   }
  433. } /* FreeGadgets */
  434.  
  435.  
  436.  
  437. /***************************************************************************
  438.  *
  439.  * This section handles the Mouse pointer for the custom screen
  440.  *
  441.  **************************************************************************/
  442.  
  443. /***************************************************************/
  444. /*  This is the image for baby Mandelbrot pointer              */
  445. /***************************************************************/
  446.  
  447. USHORT BabyBrotSprite[]=  {
  448.      /*plane1  plane0 */
  449.       0x0000,  0x0000,
  450.       0x8000,  0x0000,
  451.       0x0000,  0x5000,
  452.       0x2000,  0x2202,
  453.       0x1600,  0x5f82,
  454.       0x0802,  0x1913,
  455.       0x1152,  0x11fe,
  456.       0x1008,  0x300a,
  457.       0x0404,  0x1c06,
  458.       0x0006,  0x1407,
  459.       0x0404,  0x0404,
  460.       0x000c,  0x042c,
  461.       0x0400,  0x0c1c,
  462.       0x0220,  0x0630,
  463.       0x01e0,  0x05f0,
  464.       0x0c80,  0x3f80,
  465.       0x0000,  0x0880,
  466.       0x0000,  0x0000,
  467.      };
  468.  
  469. /***************************************************************/
  470. /*  This is a baby brot pointer with 'TO' in it.               */
  471. /***************************************************************/
  472. USHORT BabyToSprite[]=  {
  473.      /*plane1  plane0 */
  474.       0x0000,  0x0000,
  475.       0x8000,  0x0000,
  476.       0x0100,  0x5100,
  477.       0x2000,  0x2202,
  478.       0x1600,  0x5f82,
  479.       0xfe7a,  0x0103,
  480.       0x93de,  0x0132,
  481.       0x108c,  0x200a,
  482.       0x5484,  0x4c02,
  483.       0x1086,  0x0403,
  484.       0x1484,  0x0400,
  485.       0x10cc,  0x0420,
  486.       0x3c78,  0x0404,
  487.       0x0220,  0x0630,
  488.       0x01e0,  0x05f0,
  489.       0x0c80,  0x3f80,
  490.       0x0000,  0x0880,
  491.       0x0000,  0x0000,
  492.      };
  493.  
  494. /***************************************************************/
  495. /*  This is a sleepy cloud pointer                             */
  496. /***************************************************************/
  497. USHORT SleepySprite[] = {
  498.       0x0000,  0x0000,
  499.       0x0fe0,  0x0000,
  500.       0x1830,  0x07c0,
  501.       0x7018,  0x0fe0,
  502.       0xc008,  0x3ff0,
  503.       0x9e0c,  0x7ff0,
  504.       0x8406,  0x7ff8,
  505.       0x8802,  0x7ffc,
  506.       0x1e03,  0xfffc,
  507.       0x80f1,  0x7ffe,
  508.       0x8021,  0x7ffe,
  509.       0x4040,  0x3fff,
  510.       0x80f1,  0x7ffe,
  511.       0xc001,  0x3ffe,
  512.       0x6003,  0x1ffc,
  513.       0x3006,  0x0ff8,
  514.       0x180c,  0x07f0,
  515.       0x0718,  0x00e0,
  516.       0x0070,  0x0f80,
  517.       0x1810,  0x07e0,
  518.       0x0820,  0x0740,
  519.       0x0ff0,  0x0000,
  520.       0x0020,  0x03c0,
  521.       0x0410,  0x03e0,
  522.       0x0310,  0x00e0,
  523.       0x00e0,  0x0000,
  524.       0x0000,  0x0000,
  525.      };
  526.  
  527. /* defines for the cute pointer sprite */
  528. #define MYSPRITE_WIDTH 16
  529. #define MYSPRITE_HEIGHT 16
  530. #define SLEEPY_WIDTH 16
  531. #define SLEEPY_HEIGHT 25
  532. #define MYSPRITE_HOTX -1
  533. #define MYSPRITE_HOTY 0
  534.  
  535. #define BABYSIZE   ( (MYSPRITE_HEIGHT + 2) * 8)
  536. #define TOSIZE     ( (MYSPRITE_HEIGHT + 2) * 8)
  537. #define SLEEPYSIZE ( (SLEEPY_HEIGHT + 2) * 8)
  538.  
  539. /*
  540.  * Copy an Image into a chip ram image
  541.  */
  542. USHORT *MakeChipSprite( FastRamSprite, Size )
  543.   USHORT *FastRamSprite;
  544.   int    Size;
  545. {
  546.   USHORT *ChipSprite, *SaveSprite, *AllocaMem();
  547.   int i;
  548.  
  549.   ChipSprite = AllocMem( (LONG) (Size * sizeof(SHORT)), MEMF_CHIP );
  550.  
  551.   if ( ChipSprite == (struct USHORT * ) NULL )
  552.     return ( ChipSprite );
  553.  
  554.   SaveSprite = ChipSprite;
  555.  
  556.   for ( i = 0; i < Size; i++)
  557.     *(ChipSprite++) = *(FastRamSprite++);
  558.  
  559.   return( SaveSprite );
  560. }
  561.  
  562. /*
  563.  * Allocate all the mouse pointer sprites used by this program
  564.  */
  565. AllocateMice()
  566. {
  567.   BabyBrotPointer = MakeChipSprite( BabyBrotSprite, BABYSIZE );
  568.   BabyToPointer   = MakeChipSprite( BabyToSprite,   TOSIZE );
  569.   SleepyPointer   = MakeChipSprite( SleepySprite,   SLEEPYSIZE );
  570. }
  571.  
  572. /*
  573.  * Free all the mouse pointer sprites used by this program
  574.  */
  575. FreeMice()
  576. {
  577.  
  578.   if ( BabyBrotPointer )
  579.     FreeMem( BabyBrotPointer, BABYSIZE * sizeof(SHORT) );
  580.   BabyBrotPointer = NULL;
  581.  
  582.   if ( BabyToPointer )
  583.     FreeMem( BabyToPointer, TOSIZE * sizeof(SHORT) );
  584.   BabyToPointer = NULL;
  585.  
  586.   if ( SleepyPointer )
  587.     FreeMem( SleepyPointer, SLEEPYSIZE * sizeof(SHORT) );
  588.   SleepyPointer = NULL;
  589. }
  590.  
  591. /*
  592.  * Set all window pointers NewPointer
  593.  */
  594. SetPointers( NewPointer, Height, Width)
  595.   USHORT *NewPointer;
  596.   int     Height, Width;
  597. {
  598.   if (NewPointer == (struct USHORT *) NULL )
  599.     return();
  600.  
  601.   if ( ContWind )
  602.     SetPointer( ContWind, NewPointer, Height,   Width,
  603.                                      MYSPRITE_HOTX, MYSPRITE_HOTY);
  604.   if ( MandWind )
  605.     SetPointer( MandWind, NewPointer, Height,  Width,
  606.                                      MYSPRITE_HOTX, MYSPRITE_HOTY);
  607.   if ( PalWind )
  608.     SetPointer( PalWind,  NewPointer, Height,   Width,
  609.                                      MYSPRITE_HOTX, MYSPRITE_HOTY);
  610. }
  611.  
  612. /*
  613.  * Clear the window pointers
  614.  */
  615. ClearPointers()
  616. {
  617.     if ( MandWind ) ClearPointer( MandWind );
  618.     if ( ContWind ) ClearPointer( ContWind );
  619.     if ( PalWind )  ClearPointer( PalWind );
  620. }
  621.  
  622. /*
  623.  * Force normal pointers
  624.  */
  625. ForceNormPointer()
  626. {
  627.   PointerType = UNINITIALIZED;
  628.  
  629.   SetNormPointer();
  630. }
  631.  
  632. /*
  633.  * Set Normal Mouse Pointer
  634.  */
  635. SetNormPointer()
  636. {
  637.   if (PointerType != NORMPOINTER ) {
  638.     ClearPointers();
  639.  
  640.     SetPointers( BabyBrotPointer, MYSPRITE_HEIGHT, MYSPRITE_WIDTH );
  641.  
  642.     PointerType = NORMPOINTER;
  643.   }
  644.   CmdMode = NULL;
  645. }
  646.  
  647. /*
  648.  * Set 'To' Mouse Pointer
  649.  */
  650. SetToPointer()
  651. {
  652.   if (PointerType != TOPOINTER ) {
  653.     ClearPointers();
  654.  
  655.     SetPointers( BabyToPointer, MYSPRITE_HEIGHT, MYSPRITE_WIDTH );
  656.  
  657.     PointerType = TOPOINTER;
  658.   }
  659. }
  660.  
  661. /*
  662.  * Set Sleepy Mouse Pointer
  663.  */
  664. SetSleepyPointer()
  665. {
  666.   if (PointerType != SLEEPYPOINTER ) {
  667.     ClearPointers();
  668.  
  669.     SetPointers( SleepyPointer, SLEEPY_HEIGHT, SLEEPY_WIDTH );
  670.  
  671.     PointerType = SLEEPYPOINTER;
  672.   }
  673. }
  674.  
  675. SetSystemColors(flag)
  676.   int flag;
  677. {
  678.  
  679.   UWORD red, green, blue;
  680.  
  681.   static SHORT MenuColors[4] = { 0x0000, 0x0fff, 0x000a, 0x0b44 };
  682.   static SHORT PointerColors[4] = { 0x0000, 0x00c0, 0x0dd0, 0x0f00 };
  683.   static SHORT ColorSave[32];
  684.   static SHORT SaveFull = 0;
  685.  
  686.   int i;
  687.  
  688.   if (flag) {
  689.     if (SaveFull == 0) {
  690.       for (i = 0; i < 32; i++) {
  691.         ColorSave[i] = GetRGB4(vp->ColorMap, i);
  692.       }
  693.       /* Set the colors for the Menu */
  694.       for (i = 0; i < 4; i++) {
  695.         red = (MenuColors[i] & 0xf00) >> 8;
  696.         green = (MenuColors[i] & 0x0f0) >> 4;
  697.         blue  = (MenuColors[i] & 0x00f) ;
  698.         SetRGB4(vp, i , red , green, blue);
  699.       }
  700.  
  701.       /* Set the colors for the Mouse pointer */
  702.       for (i = 0; i < 4; i++) {
  703.         red = (PointerColors[i] & 0xf00) >> 8;
  704.         green = (PointerColors[i] & 0x0f0) >> 4;
  705.         blue  = (PointerColors[i] & 0x00f) ;
  706.         SetRGB4(vp, i + 16, red , green, blue);
  707.       }
  708.     }
  709.     SaveFull++;
  710.   } else {
  711.     if (SaveFull == 1)
  712.       LoadRGB4(vp, &ColorSave[0], 32);
  713.  
  714.     if (--SaveFull < 0) SaveFull = 0;
  715.   }
  716. }
  717.  
  718. /**************************************************************************
  719.  *
  720.  *  This code is used to display error messages on the cusom screen
  721.  *
  722.  **************************************************************************/
  723. struct IntuiText msg_txt =
  724.    {
  725.      0,
  726.      1,
  727.      JAM2,
  728.      5,
  729.      20,
  730.      NULL,
  731.      NULL,
  732.      NULL
  733.    };
  734.  
  735. struct IntuiText OK_txt =
  736.    {
  737.      0,
  738.      1,
  739.      JAM2,
  740.      5,
  741.      3,
  742.      NULL,
  743.      (UBYTE *) "OK",
  744.      NULL
  745.    };
  746.  
  747. struct IntuiText NO_txt =
  748.    {
  749.      0,
  750.      1,
  751.      JAM2,
  752.      5,
  753.      3,
  754.      NULL,
  755.      (UBYTE *) "NO",
  756.      NULL
  757.    };
  758.  
  759.  
  760. DispErrMsg(ErrMsg, Flag)
  761.   UBYTE *ErrMsg;
  762.   SHORT  Flag;
  763. {
  764.   msg_txt.IText = ErrMsg;
  765.  
  766.   SetNormPointer();
  767.  
  768.   if (MandWind) {
  769.     SetSystemColors(1);
  770.     if (Flag) {
  771.  
  772.       AutoRequest(MandWind, &msg_txt, &OK_txt, &NO_txt, 0L, 0L,
  773.          (long) (IntuiTextLength(&msg_txt) + 50L), 70L);
  774.     } else {
  775.  
  776.       AutoRequest(MandWind, &msg_txt, 0L, &OK_txt, 0L, 0L,
  777.          (long) (IntuiTextLength(&msg_txt) + 50L), 70L);
  778.     }
  779.     SetSystemColors(0);
  780.   } else {
  781.     printf("%s\n", ErrMsg);
  782.   }
  783. }
  784.  
  785.  
  786.  
  787.